from rest_framework import serializers
from ..models import DeviceInfo


class DeviceInfoSerializer(serializers.ModelSerializer):
    """
    设备信息序列化
    """

    class Meta:
        model = DeviceInfo
        fields = '__all__'


class DeviceInfoListSerializer(serializers.ModelSerializer):
    """
    设备列表序列化
    """

    class Meta:
        model = DeviceInfo
        fields = ('id', 'ip', 'businesses', 'labels', 'status', 'device_type', 'os_type')
        depth = 1


class DeviceListSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    ip = serializers.CharField(source='ip')
    name = serializers.CharField(source='hostname')
